package com.chixing.day03;

/**
 * @author Y2014188432
 */
public class Account {
    public String accNo ;
    public String accName ;
    public String accPassword;
    public String accTelNo;
    public double accBalance ;
    public int accType;

    public Account() {
    }

    public Account(String accNo, String accName, String accPassword, String accTelNo, double accBalance, int accType) {
        this.accNo = accNo;
        this.accName = accName;
        this.accPassword = accPassword;
        this.accTelNo = accTelNo;
        this.accBalance = accBalance;
        this.accType = accType;
    }

    @Override
    public String toString() {
        return "Account{" +
                "accNo='" + accNo + '\'' +
                ", accName='" + accName + '\'' +
                ", accPassword='" + accPassword + '\'' +
                ", accTelNo='" + accTelNo + '\'' +
                ", accBalance=" + accBalance +
                ", accType=" + accType +
                '}';
    }

    /**
     * 存款
     * @param num 存款金额
     * @return 是否成功
     */
    public boolean depoist(int num){
        accBalance += num;
        return true;
    }

    /**
     * 取款
     * @param num 取款金额
     * @return 是否成功
     */
    public boolean withdraw(int num){
        if(num > accBalance){
            return false;
        }else {
            accBalance -= num;
            return true;
        }
    }
}
